export function getPrefixCls(type: string) {
	return 'kd-' + type
}

type BaseHelperProps = {
	width?: number | string
	height?: number | string
}

function concatStyle(props: BaseHelperProps & { style?: React.CSSProperties }): React.CSSProperties {
	let _style = {
		...props.style,
	}
	if (props.width) {
		_style = {
			..._style,
			width: props.width,
		}
	}
	if (props.height) {
		_style = {
			..._style,
			height: props.height,
		}
	}
	return _style
}

export function restPropsHelper(rest: React.HTMLAttributes<any> & BaseHelperProps) {
	const { style, width, height, ...restProps } = rest
	return {
		style: concatStyle({ style, width, height }),
		...restProps,
	}
}

export function omit<T extends object, K extends keyof T>(obj: T, fields: K[]): Omit<T, K> {
	const clone = { ...obj }

	if (Array.isArray(fields)) {
		fields.forEach((key) => {
			delete clone[key]
		})
	}

	return clone
}
